package com.lovo.game;

import java.util.InputMismatchException;


public class Boxinggame {
    public Computer computer = new Computer();
    public Player player = new Player();

    public static void main(String[] args) {
        Boxinggame b = new Boxinggame();
        int fraction = b.judge();
        System.out.println("您最终分数为：" + fraction);
        if (fraction < 0) {
            System.out.println("垃圾啊");
        } else if (fraction < 60) {
            System.out.println("小废物");
        } else if (fraction < 80) {
            System.out.println("狗运");
        } else {
            System.out.println("你应该去买彩票，赌狗");
        }
    }

    public int judge() {
        int fraction = 50;
        for (int i = 0; i < 10; i++) {
            try {
                computer.generate();
                int num1 = computer.getNumber();
                player.generate();
                int num = player.getNumber();
                if (num >= 1 && num <= 3) {
                    if (num == num1) {
                        System.out.println("您与电脑平局加2分");
                        fraction += 1;
                    } else if (num == 1 && num1 == 2 || num == 2 && num1 == 3 || num == 3 && num1 == 1) {
                        System.out.println("您赢啦加5分");
                        fraction += 3;
                    } else if (num == 1 && num1 == 3 || num == 2 && num1 == 1 || num == 3 && num1 == 2) {
                        System.out.println("您输啦扣10分");
                        fraction -= 5;
                    }
                } else {
                    System.out.println("输入无效，请重新输入");
                    i--;
                }
            } catch (InputMismatchException e) {
                System.out.println("输入无效，请重新输入");
                i--;
            }
        }
        return fraction;
    }
}
